package com.tn.wservice.validator;

import java.util.ArrayList;
import java.util.List;

public class ValidationResultImp implements IValidationResult {

	List<String> errorMsgs = new ArrayList<String>();
	private Result result;

	public ValidationResultImp() {
		this.result = Result.SUCCESS;
	}

	public void addErrorMsg(String errorMsg) {
		this.getErrorMsgs().add(errorMsg);
	}

	@Override
	public Result getResult() {
		return this.result;
	}

	public void setResult(Result result) {
		this.result = result;
	}

	public void setErrorMsgs(List<String> errorMsgs) {
		this.errorMsgs = errorMsgs;
	}

	public List<String> getErrorMsgs() {
		return errorMsgs;
	}

	@Override
	public void merge(IValidationResult validateResult) {
		if (validateResult.getResult() == Result.FAILURE) {
			this.result = Result.FAILURE;
		}

		this.errorMsgs.addAll(validateResult.getErrorMsgs());
	}
}
